package com.cadre.web.controller.officer;

import com.cadre.common.utils.R;
import com.cadre.common.utils.oldutil.ValidatorUtils;
import com.cadre.system.domain.officer.DPersontagEntity;
import com.cadre.system.service.A01Service;
import com.cadre.system.service.DPersontagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Api(tags = {"工作经历标签接口"})
@RequestMapping({"/profess/dpersontag"})
@RestController
/* loaded from: DPersontagController.class */
public class DPersontagController {
    @Autowired
    private DPersontagService dPersontagService;
    @Resource
    private A01Service a01Service;

    @RequestMapping({"/list"})
    public R list(@RequestParam Map<String, Object> params) throws IOException {
        return R.ok().put("page", (Object) this.dPersontagService.tagSearch(params));
    }

    @RequestMapping({"/info/{personid}"})
//    @RequiresPermissions({"profess:dpersontag:info"})
    public R info(@PathVariable("personid") String personid) {
        return R.ok().put("dPersontag", (Object) ((DPersontagEntity) this.dPersontagService.getBaseMapper().selectById(personid)));
    }

    @GetMapping({"/getWorkTag"})
    @ApiOperation("根据人员ID获取工作经历标签信息")
    public R getWorkTag(String personid) {
        Map<String, Object> params = new HashMap<>();
        params.put("tagid", 53);
        params.put("personid", personid);
        return R.ok().put("tag", (Object) this.dPersontagService.getWorkTag(params));
    }

    @RequestMapping({"/initTag"})
    public R initPersonTag() {
        this.dPersontagService.initPersonTag(this.a01Service.selectA0177List());
        return R.ok("标签初始化完成！！！");
    }

    @RequestMapping({"/save"})
//    @RequiresPermissions({"profess:dpersontag:save"})
    public R save(@RequestBody DPersontagEntity dPersontag) {
        this.dPersontagService.save(dPersontag);
        return R.ok();
    }

    @RequestMapping({"/update"})
//    @RequiresPermissions({"profess:dpersontag:update"})
    public R update(@RequestBody DPersontagEntity dPersontag) {
        ValidatorUtils.validateEntity(dPersontag, new Class[0]);
        this.dPersontagService.updateById(dPersontag);
        return R.ok();
    }

    @RequestMapping({"/delete"})
//    @RequiresPermissions({"profess:dpersontag:delete"})
    public R delete(@RequestBody String[] personids) {
        this.dPersontagService.removeBatchByIds(Arrays.asList(personids));
        return R.ok();
    }
}
